home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / mui / mui-tools / multiuser / src / support / logout.c < prev    next >
C/C++ Source or Header  |  1995-03-09  |  2KB  |  86 lines

  1. /************************************************************
  2. * MultiUser - MultiUser Task/File Support System                *
  3. * ---------------------------------------------------------    *
  4. * Logout                                                                        *
  5. * ---------------------------------------------------------    *
  6. * © Copyright 1993-1994 Geert Uytterhoeven                        *
  7. * All Rights Reserved.                                                    *
  8. ************************************************************/
  9.  
  10.  
  11. #include <exec/types.h>
  12. #include <dos/dos.h>
  13. #include <proto/exec.h>
  14. #include <proto/dos.h>
  15. #include <utility/tagitem.h>
  16. #include <libraries/multiuser.h>
  17. #include <proto/multiuser.h>
  18.  
  19. #include "Logout_rev.h"
  20.  
  21. #include "Locale.h"
  22.  
  23. char __VersTag__[] = VERSTAG;
  24.  
  25.  
  26. int __saveds Start(char *arg)
  27. {
  28.     struct ExecBase *SysBase;
  29.     struct DosLibrary *DOSBase;
  30.     struct muBase *muBase = NULL;
  31.     struct RDArgs *args;
  32.     LONG argarray[] = {
  33.         NULL, NULL, NULL, NULL, NULL, NULL
  34.     };
  35.     struct TagItem tags[6];
  36.     struct Task *task = NULL;
  37.     int rc = RETURN_ERROR;
  38.     struct LocaleInfo li;
  39.  
  40.     SysBase = *(struct ExecBase **)4;
  41.  
  42.     if ((!(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 37))) ||
  43.          (!(muBase = (struct muBase *)OpenLibrary("multiuser.library", 39)))) {
  44.         rc = ERROR_INVALID_RESIDENT_LIBRARY;
  45.         goto Exit;
  46.     }
  47.  
  48.     OpenLoc(&li);
  49.  
  50.     args = ReadArgs("GUI/S,TASK/K,GLOBAL/S,QUIET/S,PROCESS/K/N,ALL/S",
  51.                          argarray, NULL);
  52.     if (!args)
  53.         PrintFault(IoErr(), NULL);
  54.     else if (argarray[1] && argarray[4])
  55.         PutStr(GetLocS(&li,MSG_BOTH_TASKPROC));
  56.     else if (argarray[1] && !(task = FindTask((char *)argarray[1])))
  57.         VPrintf(GetLocS(&li,MSG_TASKNOTFOUND), (ULONG *)&argarray[1]);
  58.     else if (argarray[4] &&
  59.                 !(task = (struct Task *)FindCliProc((ULONG)*(ULONG *)argarray[4])))
  60.         VPrintf(GetLocS(&li,MSG_PROCNOTFOUND), (ULONG *)argarray[4]);
  61.     else {
  62.         tags[0].ti_Tag = muT_Graphical;
  63.         tags[0].ti_Data = argarray[0];
  64.         tags[1].ti_Tag = muT_Task;
  65.         tags[1].ti_Data = (ULONG)task;
  66.         tags[2].ti_Tag = muT_Global;
  67.         tags[2].ti_Data = argarray[2];
  68.         tags[3].ti_Tag = muT_Quiet;
  69.         tags[3].ti_Data = argarray[3];
  70.         tags[4].ti_Tag = muT_All;
  71.         tags[4].ti_Data = argarray[5];
  72.         tags[5].ti_Tag = TAG_DONE;
  73.         muLogoutA(tags);
  74.         rc = RETURN_OK;
  75.     }
  76.     FreeArgs(args);
  77.  
  78.     CloseLoc(&li);
  79.  
  80. Exit:
  81.     CloseLibrary((struct Library *)muBase);
  82.     CloseLibrary((struct Library *)DOSBase);
  83.  
  84.     return(rc);
  85. }
  86.